// 处理数据
const resolvePost = (req) =>
  new Promise((resolve) => {
    let chunk = ''
    req.on('data', (data) => {
      chunk += data // 二进制
    })
    req.on('end', () => {
      resolve(JSON.parse(chunk))
    })
  })

// 获取后缀 .jpg
const extractExt = (fileName) =>
  fileName.slice(fileName.lastIndexOf('.'), fileName.length)

module.exports = {
  resolvePost,
  extractExt,
}
